import { defineStore } from 'pinia';
import {useRouter} from 'vue-router';
import { filterAsyncRoutes } from './handle.ts'
export const useMainStore = defineStore('routesList', {
	state: () => ({
		token: '',
            name: '',
            isCollapse: false,
            authBtnList: ['edit', 'delete'],
            sidebarRoutes: [],
	}),
	actions: {
		// 生成路由
        GenerateRoutes() {
            return new Promise(resolve => {
                // getMyMenusTree()
				const router =useRouter()
                const res = router.options.routes
                const asyncRouter = filterAsyncRoutes(res)
                // 合并完整路由
                this.sidebarRoutes = asyncRouter
                resolve(asyncRouter)
            })
        }
	},
});
